class BlockRender():
    def __init__(self):
        self.TEXTURE_PATH = 'texture.png'

        self.BLOCKS = {
            'STONE':self.tex_coords((0, 2), (0, 2), (0, 2)),
            'GRASS':self.tex_coords((1, 0), (0, 1), (0, 0)),
            'DIRT':self.tex_coords((0, 1), (0, 1), (0, 1)),
            'SAND':self.tex_coords((1, 1), (1, 1), (1, 1)),
            'BRICK':self.tex_coords((2, 0), (2, 0), (2, 0)),
            'BEDROCK':self.tex_coords((2, 1), (2, 1), (2, 1)),
        }

    def cube_vertices(self, x, y, z, n):
        """ 
        Return the vertices of the cube at position x, y, z with size 2*n.

        """
        return [
            x - n, y + n, z - n, x - n, y + n, z + n, x +
            n, y + n, z + n, x + n, y + n, z - n,  # top
            x - n, y - n, z - n, x + n, y - n, z - n, x + \
            n, y - n, z + n, x - n, y - n, z + n,  # bottom
            x - n, y - n, z - n, x - n, y - n, z + n, x - \
            n, y + n, z + n, x - n, y + n, z - n,  # left
            x + n, y - n, z + n, x + n, y - n, z - n, x + \
            n, y + n, z - n, x + n, y + n, z + n,  # right
            x - n, y - n, z + n, x + n, y - n, z + n, x + \
            n, y + n, z + n, x - n, y + n, z + n,  # front
            x + n, y - n, z - n, x - n, y - n, z - n, x - \
            n, y + n, z - n, x + n, y + n, z - n,  # back
        ]

    def tex_coord(self, x, y, n=4):
        """ Return the bounding vertices of the texture square.

        """
        self.m = 1.0 / n
        self.dx = x * self.m
        self.dy = y * self.m
        return self.dx, self.dy, self.dx + self.m, self.dy, self.dx + self.m, self.dy + self.m, self.dx, self.dy + self.m

    def tex_coords(self, top, bottom, side):
        """ Return a list of the texture squares for the top, bottom and side.

        """
        top = self.tex_coord(*top)
        bottom = self.tex_coord(*bottom)
        side = self.tex_coord(*side)
        self.result = []
        self.result.extend(top)
        self.result.extend(bottom)
        self.result.extend(side * 4)
        return self.result